(function( $ ) {
	jQuery.fn.prePopulate = function( json, options ) {
		if(json == undefined) {
			return this;
		}
		var settings = $.extend( { }, options);
		
		$.each(this.find('input'),function(index, inputElement) { 
			if(json[inputElement.name]) {
				switch(inputElement.type) {
					case 'text':
						$(inputElement).val(json[inputElement.name]);
						break;
					case 'radio':
						if($(inputElement).val() == json[inputElement.name]) {
							$(inputElement).attr("checked", "checked");
						}
						break;
				}
			}
	 });
	 
	 $.each(this.find('textarea'),function(index, inputElement) {
		 if(json[inputElement.name]) {
				$(inputElement).html(json[inputElement.name]);
		 }
	 });
	 
	 $.each(this.find('select'),function(index, inputElement) {
		 if(json[inputElement.name]) {
				$(inputElement).val(json[inputElement.name]);
		 }
	 });
		
		return this;
	};
})( jQuery );